<template>
  <div>
<!--    <h1> 祖孙组件传参使用 provide/inject</h1>-->
    <Son/>
    <Son2/>
    <br>
    <h1 >祖页面的函数值：{{ output }}</h1>
  </div>
</template>

<script>
import Son from './Son.vue'
import Son2 from './Son2.vue'
import { ref,provide } from "vue";

export default {
  components: {
    Son,
    Son2
  },
  setup() {
    let input = ref("祖组件传参了")
    let output = ref("")
    provide("input", input);
    let updateFunction =(value)=>{
      output.value = value
    }
    provide("updateFunction", updateFunction);
    let cde =  [1,2,3].map(function (x) {
      return x * x;
    });
    console.log(cde)
    return{
      input,
      output
    }
  }
}
</script>
<style scoped>
a {
  color: #42b983;
}

label {
  margin: 0 0.5em;
  font-weight: bold;
}

code {
  background-color: #eee;
  padding: 2px 4px;
  border-radius: 4px;
  color: #304455;
}
</style>
